<?php
use \Workerman\Autoloader;

require_once __DIR__ . '/../../../../../Workerman/Autoloader.php';
require_once __DIR__.'/../../../Config/Const.php';
Autoloader::setRootPath(__DIR__.'/../../..');

$page_groupId = GROUP_QUESTION_MNG;

require "../framepages/moudle_base.php";

$question_id = $_GET['question_id'];
$question_record = \Data\Tree_question_DAO::getRecord($question_id);
$question_content = $question_record->getQUESTION_CONTENT();
$question_response = $question_record->getQUESTION_RESPONSE();

$result = 'normal';
$mode = $_POST['mode'];
if ($mode == 'to_response') {
    $question_response = $_POST['question_response'];
    echo "$question_response";
    $question_record->setQUESTION_RESPONSE($question_response);
    $question_record->setSTATE(STATE_YES);
    \Data\Tree_question_DAO::update($question_record);
    $result = 'suc';
}
?>
<div class="main-content">
    <div>
        <div><h4>问题内容:</h4></div>
        <div style="margin-left:10%; width: 310px;height: 250px;border:1px solid #c0c0c0">
            <?php echo $question_content ?>
        </div>
    </div>
    <?php
    require "../framepages/footer.php";
    ?>

    <div>
        <div><h4>回复内容:</h4></div>
        <div style="margin-left:10%;">
            <form action="" method="post" onSubmit="javascript:return window.confirm('确认提交吗？')">
                <input type="hidden" name="mode" value="to_response">
                <textarea name="question_response" rows="8" cols="40"><?php echo $question_response ?></textarea>
                <div style="margin-top:30px;margin-left: 15%;">
                    <input type="submit" class="btn btn-danger" value="提交">
                </div>
            </form>
        </div>
    </div>
</div>
</div>
<script src="../lib/bootstrap/js/bootstrap.js"></script>
<script>
    function init() {
        var result = "<?php echo $result ?>";
        if (result == 'suc') {
            alert("提交成功");
        }
        var mode = "<?php echo $mode ?>";
        if (mode) {
            window.location.href = "question_to_response.php?question_id="+"<?php echo $question_id ?>";
        }
    }
</script>


</body>
</html>
